package com.augurit.gzcgwsp.ywcmn.convert;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.dozer.DozerBeanMapper;
import com.augurit.common.util.lang.DateUtils;
import com.augurit.gzcgwsp.ywcmn.entity.YwComClxx;
import com.augurit.gzcgwsp.ywcmn.web.form.YwComClxxForm;

public class YwComClxxConvertor {
	public static YwComClxxForm convertVoToForm(YwComClxx entity) {
		if (entity == null) return null;
		YwComClxxForm form = new DozerBeanMapper().map(entity, YwComClxxForm.class);
			return form;
	}
	
	public static void convertFormToVo(YwComClxxForm form, YwComClxx entity) {
		if (form == null) return;
        if (entity == null) entity = new YwComClxx();
        
        new DozerBeanMapper().map(form, entity);
	}
	
	public static List<YwComClxxForm> convertVoListToFormList(List<YwComClxx> ywComClxxList) {
		if(ywComClxxList != null && ywComClxxList.size() > 0) {
			List<YwComClxxForm> ywComClxxFormList = new ArrayList();
			for(int i=0; i<ywComClxxList.size(); i++) {
				ywComClxxFormList.add(convertVoToForm(ywComClxxList.get(i)));
			}
			return ywComClxxFormList;
		}
		return null;
	}
	
	public static List<Map> convertVoListToMapList(List<YwComClxx> ywComClxxList) {
		if(ywComClxxList != null && ywComClxxList.size() > 0) {
			List<Map> mapList = new ArrayList();
			for(int i=0; i<ywComClxxList.size(); i++) {
				YwComClxx entity = ywComClxxList.get(i);
				Map<String, String> map = new HashMap();

				map.put("id", entity.getId() == null ? "" : entity.getId().toString());
				map.put("fkid", entity.getFkid() == null ? "" : entity.getFkid().toString());
				map.put("clph", entity.getClph());
				map.put("zybh", entity.getZybh());
				map.put("yxq", DateUtils.dateTimeToString(entity.getYxq(), "yyyy-MM-dd"));
				map.put("ccrq", DateUtils.dateTimeToString(entity.getCcrq(), "yyyy-MM-dd"));
				map.put("djrq", DateUtils.dateTimeToString(entity.getDjrq(), "yyyy-MM-dd"));
				map.put("cx", entity.getCx());
				map.put("zzl", entity.getZzl());
				map.put("cjh", entity.getCjh());
				map.put("fdjh", entity.getFdjh());
				map.put("gps", entity.getGps());
				map.put("sfhg1", entity.getSfhg1());
                map.put("sfhg2", entity.getSfhg2());
				map.put("sfmf", entity.getSfmf());
				map.put("wzqk", entity.getWzqk());
                map.put("sfbf", entity.getSfbf());
                map.put("bfyy", entity.getBfyy());
                map.put("zbs", entity.getZbs());
                
				mapList.add(map);
			}
			return mapList;
		}
		return null;
	}
	
	public static List<YwComClxx> convertFormListToVoList(List<YwComClxxForm> ywComClxxFormList) {
		if(ywComClxxFormList != null && ywComClxxFormList.size() > 0) {
			List<YwComClxx> ywComClxxList = new ArrayList();
			for(int i=0; i<ywComClxxFormList.size(); i++) {
				YwComClxx ywComClxx = new YwComClxx();
				convertFormToVo(ywComClxxFormList.get(i), ywComClxx);
				ywComClxxList.add(ywComClxx);
			}
			return ywComClxxList;
		}
		return null;
	}
}